1 /*
  2 * Copyright (c) 2014 Nonki Takahashi. All rights reserved.
  3 *
  4 * History:
  5 *  0.1 2014-01-10 Created.
  6 */
  7 
  8 /**
  9  * @fileOverview Lex Specification - Lexical Analyzer Spec for Jasmine
 10  * @version 0.2
 11  * @author Nonki Takahashi
 12  */
 13 
 14 describe("Lex 仕様 0.2", function() {
 15   var exp = "1+2=";
 16   var la;
 17 
 18   beforeEach(function() {
 19     la = new Lex(exp);	// Lexical Analiser
 20   });
 21 
 22   it("eod() は false を返す", function() {
 23     expect(la.eod()).toBeFalsy();
 24   });
 25 
 26   it("digit() は '1' を返す", function() {
 27     expect(la.digit()).toEqual('1');
 28   });
 29 
 30   it("upper() は null を返す", function() {
 31     expect(la.upper()).toBe(null);
 32   });
 33 
 34   it("lower() は null を返す", function() {
 35     expect(la.lower()).toBe(null);
 36   });
 37 
 38   it("sp() は null を返す", function() {
 39     expect(la.sp()).toBeFalsy();
 40   });
 41 
 42   it("sq() は null を返す", function() {
 43     expect(la.sq()).toBeFalsy();
 44   });
 45 
 46   it("ch('1') は '1' を返す", function() {
 47     expect(la.ch('1')).toEqual('1');
 48   });
 49 
 50   describe("3文字読んだ時点で、", function() {
 51     beforeEach(function() {
 52       la.rewind();
 53       la.digit();
 54       la.ch('+');
 55       la.digit();
 56     });
 57 
 58     it("eod() は false を返す", function() {
 59       expect(la.eod()).toBe(false);
 60     });
 61 
 62     it("digit() は null を返す", function() {
 63       expect(la.digit()).toBe(null);
 64     });
 65 
 66     it("upper() は null を返す", function() {
 67       expect(la.upper()).toBe(null);
 68     });
 69 
 70     it("lower() は null を返す", function() {
 71       expect(la.lower()).toEqual(null);
 72     });
 73 
 74     it("ch('=') は '=' を返す", function() {
 75       expect(la.ch('=')).toBe('=');
 76     });
 77 
 78   });
 79 
 80   describe("4文字読んだ時点で、", function() {
 81     beforeEach(function() {
 82       la.rewind();
 83       la.digit();
 84       la.ch('+');
 85       la.digit();
 86       la.ch('=');
 87     });
 88 
 89     it("eod() は true を返す", function() {
 90       expect(la.eod()).toBeTruthy();
 91     });
 92 
 93   });
 94 
 95 });
 96